package com.junzhiit.nengji.shop.model.enums;

import com.bainaeco.framework.exception.InvalidArgumentException;

public enum OrderStatus {
	
	WAIT(0,"待付款"),
	PAID(1,"已付款"),
	SHIPPED(2,"已发货(直邮)/已配送(配送)"),
	CONFIRM(3,"确认收货/待评价"),
	WAITUSE(4,"待使用"),
	HASUSE(5,"已使用"),
	COMPLETE(6,"完成订单"),
	CANCEL(7,"取消订单"),
	FAILIN(8,"退货/退款中"),
	FAIL(9,"退货/退款成功"),
	ACCEPT(10,"商家已接单(配送/自提)");
	
	private Integer value;
	private String text;

	private OrderStatus(Integer value,String text) {
		this.value = value;
		this.text = text;
	}

	public Integer toIntValue() {
		return this.value;
	}
	
	public String toStringText() {
		return this.text;
	}

	public static OrderStatus toStatus(Integer value) {
		if (WAIT.value == value) {
			return WAIT;
		} else if (PAID.value == value) {
			return PAID;
		}else if (SHIPPED.value == value) {
			return SHIPPED;
		}else if (CONFIRM.value == value) {
			return CONFIRM;
		}else if (COMPLETE.value == value) {
			return COMPLETE;
		}else if (CANCEL.value == value) {
			return CANCEL;
		}else if (FAILIN.value == value) {
			return FAILIN;
		}else if (FAIL.value == value) {
			return FAIL;
		}else if(WAITUSE.value == value){
			return WAITUSE;
		}else if(HASUSE.value == value){
			return HASUSE;
		}else if(ACCEPT.value == value){
			return ACCEPT;
		}else {
			throw new InvalidArgumentException("Unknown OrderStatus[" + value + "].");
		}
	}
}
